<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
    pageContext.setAttribute("PAGETITLE", "用户列表");
%>
<%@ include file="/pages/include/header.jsp" %>

<script type="text/javascript">
<!--
function cmd(command, params) {
    switch (command) {
       case "add":
           var url = ctx + "/pages/system/userEdit.jsp";
           var o = window.showModalDialog(url, null, "dialogWidth=500px; dialogHeight=600px; status=0;");
           window.location.reload();
           break;
       case "edit":
           var url = ctx + "/action/user.do?method=edit&userId=" + params.userId;
           var o = window.showModalDialog(url, null, "dialogWidth=500px; dialogHeight=600px; status=0;");
           window.location.reload();
           break;
       case "delete":
           if (window.confirm("确定删除?")) {
	           var url = ctx + "/action/user.do";
	           $.post(url, {method: "delete", userId: params.userId}, function (returnString) {
	               var i = parseInt(returnString);
	               if (0 < i) {
	                   window.location.reload();
	               } else {
		               $("#action_result").html("操作失败");
		               $("#action_result").addClass("action_result_0");
		               $C.showTips({selector: "#action_result", position: $C.P_LEFT, hide: true});
		           }
	           });
           }
           break;
       case "role":
           var url = ctx + "/pages/system/userRoleList.jsp?userId=" + params.userId;
           window.showModalDialog(url, null, "dialogWidth=500px; dialogHeight=400px; status=0;");
           break;
    }
}

$(document).ready(function () {
    $("#action_result").animate({left: -100}, 0);
});
//-->
</script>

<sql:query var="userList" dataSource="${dataSource}">
SELECT U.*, (CASE WHEN U.STATUS = '1' THEN '有效' ELSE '无效' END) STATUS2
FROM CT_USER U ORDER BY U.ORDERNO
</sql:query>

<body>

    <div class="page_header">${PAGETITLE}</div>
    
    <div class="page_buttons">
        <div id="action_result" class="action_result"></div>
        <input type="button" value="增加" onclick="cmd('add')" />
    </div>
    
    <div class="page_query">
        query div
    </div>

    <br />
    <table cellpadding="0" cellspacing="0" align="center" class="table_list">
        <thead>
            <tr>
                <td width="45">序号</td>
                <td>登录名称</td>
                <td>用户名称</td>
                <td>手机</td>
                <td>电话</td>
                <td width="65">是否有效</td>
                <td width="60">排序号</td>
                <td width="90">操作</td>
            </tr>
        </thead>
        <tbody>
            <c:forEach var="item" items="${userList.rows}" varStatus="vs">
            <tr>
                <td align="center">${vs.index + 1}</td>
                <td align="left">&nbsp;${item.LOGINNAME}</td>
                <td align="left">&nbsp;${item.USERNAME}</td>
                <td align="left">&nbsp;${item.MOBILE}</td>
                <td align="left">&nbsp;${item.TELEPHONE}</td>
                <td align="center">&nbsp;${item.STATUS2}</td>
                <td align="right">&nbsp;${item.ORDERNO}</td>
                <td align="center">
                    <a href="javascript:cmd('edit', {userId: '${item.USERID}'})">编辑</a>
                    <a href="javascript:cmd('delete', {userId: '${item.USERID}'})">删除</a>
                    <a href="javascript:cmd('role', {userId: '${item.USERID}'})">角色</a>
                </td>
            </tr>
            </c:forEach>
        </tbody>
    </table>
    
    <div class="page_footer"></div>

</body>

<%@ include file="/pages/include/footer.jsp" %>
